//
//  HiCarShareAction.m
//  HiCar
//
//  Created by huachun on 2018/12/28.
//  Copyright © 2018 丁一. All rights reserved.
//

#import "HiCarShareAction.h"

@implementation HiCarShareAction

+ (void)ios_share:(UIImage*)image titile:(NSString *)titile url:(NSString *)url target:(UIViewController *)target success:(SucceessBlock)successBlock;{

    NSURL *urlToShare = [NSURL URLWithString:url];
    //在这里呢 如果想分享图片 就把图片添加进去  文字什么的通上
    NSArray *activityItems = @[titile,image, urlToShare];
    UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
    //不出现在活动项目
    activityVC.excludedActivityTypes = @[UIActivityTypePrint, UIActivityTypeCopyToPasteboard,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll];
    [target presentViewController:activityVC animated:YES completion:nil];
    // 分享之后的回调
    activityVC.completionWithItemsHandler = ^(UIActivityType  _Nullable activityType, BOOL completed, NSArray * _Nullable returnedItems, NSError * _Nullable activityError) {
        if (completed) {
            successBlock(YES);
            //分享 成功
        } else  {
            successBlock(NO);
            NSLog(@"cancled");
            //分享 取消
        }
    };
}

@end
